using UnityEngine;
using System.Collections;

public class SceneChoises : AndroidMenu 
{
	public Transform audioPrefab;
	
	void Start()
	{
		base._manager = gameObject.GetComponent<MenuManager>();
		base.amount = _manager.amount;
		
				
		if(GameObject.Find("AudioBehavior"))
			Destroy(GameObject.Find("AudioBehavior"));
		
		gameObject.AddComponent("InputManager");
	}

	void OnTouchEnter(GameObject go)
	{
		changeColor(go);
	}
	
	void OnTouchExit(GameObject go)
	{
		go.renderer.material.color = Color.white;
	}
	
	void OnTouchUp(GameObject go)
	{
		if(ready)
		{
			if(go.name == "Back")
			{
				_manager.changeSceneAtName("Menu");
			}
			else
			{
				Transform a = Instantiate(audioPrefab,Camera.mainCamera.transform.position,Camera.mainCamera.transform.rotation) as Transform;
				a.name = "AudioBehavior";
				
				_manager.changeSceneAtName("Level"+go.name);
			}
		}
	}
	
	void changeColor(GameObject go)
	{
		Color randomColor = new Color(Random.Range(0.0f,1.0f),Random.Range(0.0f,1.0f),Random.Range(0.0f,1.0f),1);
			
		if(randomColor == Color.white)
		{
			randomColor = new Color(Random.Range(0.5f,1.0f),Random.Range(0.5f,1.0f),Random.Range(0.5f,1.0f),1);
		}
			
		go.renderer.material.color = randomColor;
	}
	
	void Ready()
	{
		ready = true;
	}
}
	